/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef INCLUDE_EDDS_RTPS_TRANSPORT_UDSDGRAMTRANSPORTDESCRIPTOR_H_
#define INCLUDE_EDDS_RTPS_TRANSPORT_UDSDGRAMTRANSPORTDESCRIPTOR_H_

#include <ertps/ertps_dll.h>

#include <transport/TransportDescriptorInterface.h>

#include <cstdint>
#include <vector>
#include <string>

namespace vbs {
namespace transport {

struct UDSDgramTransportDescriptor : public TransportDescriptorInterface {
    virtual ~UDSDgramTransportDescriptor() = default;

    RTPS_DllAPI UDSDgramTransportDescriptor()
        : TransportDescriptorInterface(65500U, 1), sendBufferSize(65535U), receiveBufferSize(65535U) {}

    RTPS_DllAPI UDSDgramTransportDescriptor(uint32_t maximumMessagerSize, uint32_t maximumInitialPeersRange)
        : TransportDescriptorInterface(maximumMessagerSize, maximumInitialPeersRange),
          sendBufferSize(0U),
          receiveBufferSize(0U) {}

    RTPS_DllAPI UDSDgramTransportDescriptor(const UDSDgramTransportDescriptor& t) = default;

    RTPS_DllAPI UDSDgramTransportDescriptor& operator=(const UDSDgramTransportDescriptor& t) = default;

    uint32_t min_send_buffer_size() const override { return sendBufferSize; }

    RTPS_DllAPI bool operator==(const UDSDgramTransportDescriptor& t) const {
        return ((this->sendBufferSize == t.sendBufferSize) && (this->receiveBufferSize == t.receiveBufferSize) &&
                (this->non_blocking_send == t.non_blocking_send) && (TransportDescriptorInterface::operator==(t)));
    }

    bool non_blocking_send = true;

    TransmitorType get_type() const override;

    TransportInterface* create_transport() const override;

    uint32_t sendBufferSize;

    uint32_t receiveBufferSize;
};

}  // namespace transport
}  // namespace vbs

#endif
